package com.fe.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fe.mapper.AreaMapper;
import com.fe.mapper.CityMapper;
import com.fe.mapper.ProvinceMapper;
import com.fe.model.Area;
import com.fe.model.City;
import com.fe.model.Province;
import com.fe.service.AddressService;
@Service
public class AddressServiceImpl implements AddressService{
	
	@Autowired
	private ProvinceMapper provinceMapper;
	@Autowired
	private CityMapper cityMapper;
	@Autowired
	private AreaMapper areaMapper;
	
	/**
     * 
     * 方法描述：三级联动查询全部省
     * @return
     * @author ssh
     * @date 2018年8月21日 下午3:04:02
     */
	@Override
	public List<Province> listProvince() {
		List<Province> listProvince = provinceMapper.listProvince();
		if (listProvince == null || listProvince.size() <= 0) {
			return null;
		}
		return listProvince;
	}

	/**
     * 
     * 方法描述：根据省的id查询，该省的所有市
     * @param province_id
     * @return
     * @author ssh
     * @date 2018年8月21日 下午3:04:59
     */
	@Override
	public List<City> listCity(Integer province_id) {
		List<City> listCity = cityMapper.listCity(province_id);
		if (listCity == null || listCity.size() <= 0) {
			return null;
		}
		return listCity;
	}

	/**
     * 
     * 方法描述：根据市的id，查询该市下所有的地区
     * @param city_id
     * @return
     * @author ssh
     * @date 2018年8月21日 下午3:08:28
     */
	@Override
	public List<Area> listArea(Integer city_id) {
		List<Area> listArea = areaMapper.listArea(city_id);
		if (listArea == null || listArea.size() <= 0) {
			return null;
		}
		return listArea;
	}

}
